﻿import axios from 'axios'
import {
    notification
} from 'ant-design-vue'
import {
    options
} from 'less';

function request(option) {
    return axios(option).then(res => res).catch(error => {
        const {
            response: {
                status,
                statusText
            }
        } = error;
        notification.error({
            //eslint-disable-next-line no-unused-vars
            message: h => (
                <div>
                    请求错误<span style="color:red">{status}</span>:{option.url}
                </div>
            ),
            description: statusText
        });
        //请求的时候错误信息就不会进入到then里面了，而是通过catch处理
        return Promise.reject(error);
    })
}
export default request